﻿using UniRx;
using System;

/// <summary>
/// 怪物属性
/// </summary>
public class MonsterAttribute : UnitAttributeBase
{
    #region 属性

    /// <summary>
    /// 经验值
    /// </summary>
    public int exp { get => m_Exp.Value; set => m_Exp.Value = value; }
    public IObservable<int> onExp => m_Exp;
    private ReactiveProperty<int> m_Exp = new ReactiveProperty<int>();

    #endregion


    public MonsterAttributeConfig config { get; private set; }

    protected override void OnInit()
    {
        config = (entity as MonsterEntity).attributeConfig;
    }

    protected override void OnSpawn()
    {
        ReloadAttribute();
    }

    private void ReloadAttribute()
    {
        level = config.level;
        baseHP = config.baseHP;
        baseAttack = config.baseAttack;
        baseDefence = config.baseDefence;
        exp = config.exp;
        defencePierce = config.defencePierce;
        critical = config.critical;
        criticalDamage = config.criticalDamage;
        knockBack = config.knockBack;
        speed = config.speed;
        jumpAbility = config.jumpAbility;
        resilience = config.resilience;
        battleResilience = config.battleResilience;
        lifeTheft = config.lifeTheft;
        counterAttack = config.counterAttack;
        attackSpeed = config.attackSpeed;
        chantReduction = config.chantReduction;
        cooldownReduction = config.cooldownReduction;
        physicalBonus = config.physicalBonus;
        geoBonus = config.geoBonus;
        hydroBonus = config.hydroBonus;
        pyroBonus = config.pyroBonus;
        anemoBonus = config.anemoBonus;
        cyroBonus = config.cyroBonus;
        electroBonus = config.electroBonus;
        phoBonus = config.photoBonus;
        skotoBonus = config.UmbroBonus;
        physicalResistance = config.physicalResistance;
        geoResistance = config.geoResistance;
        hydroResistance = config.hydroResistance;
        pyroResistance = config.pyroResistance;
        anemoResistance = config.anemoResistance;
        cryoResistance = config.cryoResistance;
        electroResistance = config.electroResistance;
        photoResistance = config.photoResistance;
        umbroResistance = config.umbroResistance;
        physicalPierce = config.physicalPierce;
        geoPierce = config.geoPierce;
        hydroPierce = config.hydroPierce;
        pyroPierce = config.pyroPierce;
        anemoPierce = config.anemoPierce;
        cryoPierce = config.cryoPierce;
        electroPierce = config.electroPierce;
        photoPierce = config.photoPierce;
        umbroPierce = config.umbroPierce;

        extraHP = 0;
        currentHP = totalHP;
        extraAttack = 0;
        extraDefence = 0;
    }
}